package com.suning.sawp.web.controller;

import java.math.BigDecimal;
import java.security.Principal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.sf.json.JSONObject;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import com.suning.framework.dal.client.DalClient;
import com.suning.nsfsmm.order.rsfservice.ExceptionOrderService;
import com.suning.nsfsmm.order.rsfservice.dto.ExpOrderDetail;
import com.suning.nsfsmm.order.rsfservice.dto.ExpOrderQueryDetailDto;
import com.suning.nsfsmm.shelf.rsfservice.IntellegentShelfService;
import com.suning.nsfsmm.shelf.rsfservice.dto.Employee;
import com.suning.nsfsmm.shelf.rsfservice.dto.ShelfAdjustDto;
import com.suning.nsfsmm.shelf.rsfservice.dto.ShelfAdjustSumDto;
import com.suning.nsfsmm.shelf.rsfservice.dto.ShelfCmmdtyDto;
import com.suning.nsfsmm.shelf.rsfservice.dto.ShelfDto;
import com.suning.nsfsmm.shelf.rsfservice.dto.ShelfShortageDto;
import com.suning.nsfsmm.shelf.rsfservice.dto.StoreShelfDto;
import com.suning.rsf.consumer.ServiceLocator;
import com.suning.sawp.constants.ClerkConstants;
import com.suning.sawp.constants.ConfigConstants;
import com.suning.sawp.constants.ErrorCodeConstants;
import com.suning.sawp.dto.bi.BiSaleAmountDto;
import com.suning.sawp.dto.bi.BiStoreSaleMonthDto;
import com.suning.sawp.dto.bi.StoreManRealIncSum;
import com.suning.sawp.dto.common.ReturnMsg;
import com.suning.sawp.dto.fastsale.AssignShelfChargerDto;
import com.suning.sawp.dto.mainpush.StoreManDto;
import com.suning.sawp.intf.bi.BiDataDaoService;
import com.suning.sawp.intf.bi.BiSaleAmountDaoService;
import com.suning.sawp.intf.storeman.StoreManService;
import com.suning.sawp.member.constant.MemberConstants;
import com.suning.sawp.po.bi.BIStaffSaleAllMonth;
import com.suning.sawp.po.bi.BIStoreSaleAllDay;
import com.suning.sawp.service.util.BigDecimalUtils;
import com.suning.sawp.service.util.DJStringUtils;
import com.suning.sawp.service.util.DateUtils;
import com.suning.sawp.service.util.SCMConfigUtil;
import com.suning.sawp.web.exception.MyGsonView;

/**
 * 
 * 货架管理控制层<br> 
 *
 * @author 14060886 祝翔龙
 */
@Controller
@RequestMapping("/fastSale")
public class FastSaleController extends DjBaseController {
    
    private static final Logger LOGGER = LoggerFactory.getLogger(FastSaleController.class);
    
    @Autowired
    private StoreManService storeManService;
    @Autowired
    private BiSaleAmountDaoService biSaleAmountDaoService;
    @Autowired
    private BiDataDaoService biDataDaoService;
    
    private ExceptionOrderService exceptionOrderService = ServiceLocator.getService(ExceptionOrderService.class, null);
    private IntellegentShelfService intellegentShelfService = ServiceLocator.getService(IntellegentShelfService.class, null);;
    
    @Autowired
    DalClient dalClient;
    
   /**
    * 
    * 功能描述: 店长/督导首页接口<br>
    *
    * @param principal
    * @return
    */
    @RequestMapping("/getIndexData.do")
    public MyGsonView getIndexData(Principal principal) {
        LOGGER.info("查询店长/督导首页接口, staffId: {}", principal.getName());
        ReturnMsg<Map<String, Object>> result = new ReturnMsg<Map<String, Object>>();
        Map<String, Object> json = new HashMap<String, Object>();
        //工号
        String staffId = principal.getName();
        //查询店员信息
        StoreManDto storeMan = storeManService.queryStoreManAttachInfo(staffId);
        //门店编号
        String storeCode = storeMan.getStoreCode();
        try {
            //卡单信息
            ExpOrderDetail expOrderDetail = queryExpOrderSummaryDetail(storeCode);
            if(null == expOrderDetail){
                result.setRetFlag(ReturnMsg.FAIL);
                result.setErrorCode(ErrorCodeConstants.ERR_FAST_SALE_0001);
                LOGGER.error("卡单信息不存在, staffId: {}", principal.getName());
                return  setGsonView(result);
            }
            JSONObject expOrderDetailJson = JSONObject.fromObject(expOrderDetail);
            //相同key直接覆盖 
            expOrderDetailJson.put("loseAmount", handleAmount(DJStringUtils.bigDecimal(expOrderDetail.getLoseAmount())));
            //卡单wap页地址
            expOrderDetailJson.element("expOrderLink", SCMConfigUtil.getConfig(ConfigConstants.FAST_S_EXP_ORDER_IDX_URL));
            //删除不需要的元素
            expOrderDetailJson.remove("errorCode");
            expOrderDetailJson.remove("errorMessage");
            expOrderDetailJson.remove("orderCmmdtyQty");
            expOrderDetailJson.remove("orderSumQty");
            expOrderDetailJson.remove("processedOrderQty");
            expOrderDetailJson.remove("unsolvedCmmdtyQty");
            json.put("expOrder", expOrderDetailJson);
            
            //货架信息
            ShelfAdjustSumDto shelfAdjustSumDto = intellegentShelfService.countAdjustShelfs(storeCode, null);
            json.put("shelfInfo", shelfAdjustSumDto);
            
            //缺货商品信息
            ShelfShortageDto shelfShortageDto = intellegentShelfService.countShortageCmmdites(storeCode, null);
            json.put("shortageCmmdtyInfo", shelfShortageDto);
            
            //今日销售
            String today = DateUtils.getDateStrByFormat(new Date(), DateUtils.YYYYMMDD_PATTERN);
            BIStoreSaleAllDay biStoreSaleToday = biSaleAmountDaoService.queryStoreSaleAllDayByStoreCode(storeCode, today);
            json.put("todaySaleAmount",  handleAmount(null != biStoreSaleToday ? biStoreSaleToday.getSaleAmount() : BigDecimal.ZERO));
            
            //昨日销售
            String yesterday = DateUtils.getDateStrByFormat(DateUtils.getNextDay(new Date(), -1), DateUtils.YYYYMMDD_PATTERN);
            BIStoreSaleAllDay biStoreSaleYest = biSaleAmountDaoService.queryStoreSaleAllDayByStoreCode(storeCode, yesterday);
            json.put("yetdSaleAmount",  handleAmount(null != biStoreSaleYest ? biStoreSaleYest.getSaleAmount() : BigDecimal.ZERO));
            
            //本月销售
            BigDecimal thisMonSaleAmount = querySaleAmount4thisMonth(storeCode);
            json.put("thisMonSaleAmount", handleAmount(thisMonSaleAmount));
            
            result.setData(json);
        } catch (Exception e) {
            result.setRetFlag(ReturnMsg.FAIL);
            result.setErrorCode(ErrorCodeConstants.ERR_0002);
            result.setErrorMessage(e.getMessage());
            LOGGER.error("查询店长/督导首页接口异常, staffId: {}", principal.getName(), e);
        }
        return setGsonView(result);
    }
    
    /**
     * 
     * 功能描述: 店员首页接口<br>
     *
     * @param principal
     * @return
     */
     @RequestMapping("/getClerkIndexData.do")
     public MyGsonView getClerkIndexData(Principal principal) {
         LOGGER.info("查询店员首页接口, staffId: {}", principal.getName());
         ReturnMsg<Map<String, Object>> result = new ReturnMsg<Map<String, Object>>();
         Map<String, Object> json = new HashMap<String, Object>();
         //工号
         String staffId = principal.getName();
         //查询店员信息
         StoreManDto storeMan = storeManService.queryStoreManAttachInfo(staffId);
         //门店编号
         String storeCode = storeMan.getStoreCode();
         try {
             //货架信息
             ShelfAdjustSumDto shelfAdjustSumDto = intellegentShelfService.countAdjustShelfs(storeCode, staffId);
             //缺货商品信息
             ShelfShortageDto shelfShortageDto = intellegentShelfService.countShortageCmmdites(storeCode, staffId);
             
             //本月销售
             BIStaffSaleAllMonth biStaffSaleAllMonth = biSaleAmountDaoService.queryStaffSaleAllMonthByStaffId(staffId);
             if(null != biStaffSaleAllMonth){
                 BigDecimal thisMonSaleAmount = biStaffSaleAllMonth.getSaleAmount();
                 json.put("thisMonSaleAmount", handleAmount(thisMonSaleAmount));
                 json.put("rank", biStaffSaleAllMonth.getRanking()); //排名
             }else{
                 json.put("thisMonSaleAmount", BigDecimal.ZERO);
             }
             
             //上月提成
             StoreManRealIncSum income = biDataDaoService.queryTotalIncomeInfo(staffId);
             json.put("todaySaleAmount",  handleAmount(null != income ? income.getTotIncome() : BigDecimal.ZERO));
             
             json.put("shelfInfo", shelfAdjustSumDto);
             json.put("shortageCmmdtyInfo", shelfShortageDto);
             result.setData(json);
         } catch (Exception e) {
             result.setRetFlag(ReturnMsg.FAIL);
             result.setErrorCode(ErrorCodeConstants.ERR_0002);
             result.setErrorMessage(e.getMessage());
             LOGGER.error("查询店员首页接口异常, staffId: {}", principal.getName(), e);
         }
         return setGsonView(result);
     }
     
     /**
      * 
      * 功能描述: 查询待处理缺货商品列表<br>
      *
      * @param principal
      * @param limit
      * @param startIndex
      * @return
      */
      @RequestMapping("/shelf/queryShortageCmmdties.do")
      public MyGsonView queryShortageCmmdties(Principal principal, Integer limit, Integer startIndex) {
          LOGGER.info("查询待处理缺货商品列表, staffId: {}, limit: {}, startIndex: {}", principal.getName(), limit, startIndex);
          ReturnMsg<ShelfShortageDto> result = new ReturnMsg<ShelfShortageDto>();
          //工号
          String staffId = principal.getName();
          //查询店员信息
          StoreManDto storeMan = storeManService.queryStoreManAttachInfo(staffId);
          //门店编号
          String storeCode = storeMan.getStoreCode();
          staffId = getStaffId(staffId, storeMan.getPositionId());
          try {
              result.setData(intellegentShelfService.queryShortageCmmdties(storeCode, staffId, startIndex, getEnd(startIndex, limit)));
          } catch (Exception e) {
              result.setRetFlag(ReturnMsg.FAIL);
              result.setErrorCode(ErrorCodeConstants.ERR_0002);
              result.setErrorMessage(e.getMessage());
              LOGGER.error("查询待处理缺货商品列表异常, staffId: {}, limit: {}, startIndex: {}", principal.getName(), limit, startIndex, e);
          }
          return setGsonView(result);
      }
      
  /**
   * 
   * 功能描述: 查询货架上商品详情<br>
   *
   * @param principal
   * @param cmmdtyCode
   * @return
   */
   @RequestMapping("/shelf/queryCmmdtyDetail.do")
   public MyGsonView queryCmmdtyDetail(Principal principal, String cmmdtyCode) {
       LOGGER.info("查询货架上商品详情, staffId: {}, cmmdtyCode: {}", principal.getName(), cmmdtyCode);
       ReturnMsg<ShelfCmmdtyDto> result = new ReturnMsg<ShelfCmmdtyDto>();
       //工号
       String staffId = principal.getName();
       //查询店员信息
       StoreManDto storeMan = storeManService.queryStoreManAttachInfo(staffId);
       //门店编号
       String storeCode = storeMan.getStoreCode();
       try {
           result.setData(intellegentShelfService.queryCmmdtyDetail(storeCode, cmmdtyCode));
       } catch (Exception e) {
           result.setRetFlag(ReturnMsg.FAIL);
           result.setErrorCode(ErrorCodeConstants.ERR_0002);
           result.setErrorMessage(e.getMessage());
           LOGGER.error("查询货架上商品详情异常, staffId: {}, cmmdtyCode: {}", principal.getName(), cmmdtyCode, e);
       }
       return setGsonView(result);
   }
       
       
   /**
    * 
    * 功能描述: 查询待调整货架详情<br>
    *
    * @param principal
    * @param adjustId
    * @param shelfNo
    * @return
    */
    @RequestMapping("/shelf/queryShelfAdjust.do")
    public MyGsonView queryShelfAdjust(Principal principal, String adjustId, String shelfNo) {
        LOGGER.info("查询待调整货架详情, staffId: {}, adjustId: {}, shelfNo: {}", principal.getName(), adjustId, shelfNo);
        ReturnMsg<ShelfAdjustDto> result = new ReturnMsg<ShelfAdjustDto>();
        //工号
        String staffId = principal.getName();
        //查询店员信息
        StoreManDto storeMan = storeManService.queryStoreManAttachInfo(staffId);
        //门店编号
        String storeCode = storeMan.getStoreCode();
        try {
            ShelfAdjustDto shelfAdjustDto = intellegentShelfService.queryShelfAdjust(storeCode, adjustId, shelfNo);
            if(null!= shelfAdjustDto){
                //日期格式化
                shelfAdjustDto.setAdjustDeadline(DateUtils.getDateStrByFormat(DateUtils.getDateByStr(shelfAdjustDto.getAdjustDeadline(), DateUtils.DEFAULT_TIME_PATTERN), 
                        DateUtils.MM_DD_HH_MM_PATTERN));
            }
            result.setData(shelfAdjustDto);
        } catch (Exception e) {
            result.setRetFlag(ReturnMsg.FAIL);
            result.setErrorCode(ErrorCodeConstants.ERR_0002);
            result.setErrorMessage(e.getMessage());
            LOGGER.error("查询待调整货架详情异常, staffId: {}, adjustId: {}, shelfNo: {}", principal.getName(), adjustId, shelfNo, e);
        }
        return setGsonView(result);
    }
    
    /**
     * 
     * 功能描述: 查询货架详情<br>
     *
     * @param principal
     * @param shelfNo
     * @return
     */
     @RequestMapping("/shelf/queryShelfDetail.do")
     public MyGsonView queryShelfDetail(Principal principal, String shelfNo) {
         LOGGER.info("查询货架详情, staffId: {}, shelfNo: {}", principal.getName(), shelfNo);
         ReturnMsg<ShelfDto> result = new ReturnMsg<ShelfDto>();
         //工号
         String staffId = principal.getName();
         //查询店员信息
         StoreManDto storeMan = storeManService.queryStoreManAttachInfo(staffId);
         //门店编号
         String storeCode = storeMan.getStoreCode();
         try {
             result.setData(intellegentShelfService.queryShelfDetail(storeCode, shelfNo));
         } catch (Exception e) {
             result.setRetFlag(ReturnMsg.FAIL);
             result.setErrorCode(ErrorCodeConstants.ERR_0002);
             result.setErrorMessage(e.getMessage());
             LOGGER.error("查询货架详情异常, shelfNo: {}", principal.getName(), shelfNo, e);
         }
         return setGsonView(result);
     }
     
     /**
      * 
      * 功能描述:店长督导分配货架责任人<br>
      *
      * @param principal
      * @param request
      * @return
      */
      @RequestMapping("/shelf/assignShelfCharger.do")
      public MyGsonView assignShelfCharger(Principal principal, @RequestBody AssignShelfChargerDto request) {
          List<Employee> employees = request.getEmployees();
          String shelfNo = request.getShelfNo();
          LOGGER.info("店长督导分配货架责任人, staffId: {}, employees: {}, shelfNo: {}", principal.getName(), employees, shelfNo);
          ReturnMsg<String> result = new ReturnMsg<String>();
          //工号
          String staffId = principal.getName();
          //查询店员信息
          StoreManDto storeMan = storeManService.queryStoreManAttachInfo(staffId);
          //门店编号
          String storeCode = storeMan.getStoreCode();
          try {
              intellegentShelfService.assignShelfCharger(storeCode, shelfNo, employees);
          } catch (Exception e) {
              result.setRetFlag(ReturnMsg.FAIL);
              result.setErrorCode(ErrorCodeConstants.ERR_0002);
              result.setErrorMessage(e.getMessage());
              LOGGER.error("店长督导分配货架责任人异常, staffId: {}, employees: {}, shelfNo: {}", principal.getName(), employees, shelfNo, e);
          }
          return setGsonView(result);
      }
     
      /**
       * 
       * 功能描述: 查询待调整货架列表<br>
       *
       * @param principal
       * @param limit
       * @param startIndex
       * @return
       */
       @RequestMapping("/shelf/queryAdjustShelfList.do")
       public MyGsonView queryAdjustShelfList(Principal principal, Integer limit, Integer startIndex) {
           LOGGER.info("查询待调整货架列表, staffId: {}, limit: {}, startIndex: {}", principal.getName(), limit, startIndex);
           ReturnMsg<StoreShelfDto> result = new ReturnMsg<StoreShelfDto>();
           //工号
           String staffId = principal.getName();
           //查询店员信息
           StoreManDto storeMan = storeManService.queryStoreManAttachInfo(staffId);
           //门店编号
           String storeCode = storeMan.getStoreCode();
           staffId = getStaffId(staffId, storeMan.getPositionId());
           try {
               result.setData(intellegentShelfService.queryAdjustShelfList(storeCode, staffId, startIndex, getEnd(startIndex, limit)));
           } catch (Exception e) {
               result.setRetFlag(ReturnMsg.FAIL);
               result.setErrorCode(ErrorCodeConstants.ERR_0002);
               result.setErrorMessage(e.getMessage());
               LOGGER.error("查询待调整货架列表异常, limit: {}, startIndex: {}", principal.getName(), limit, startIndex, e);
           }
           return setGsonView(result);
       }
       
       /**
        * 
        * 功能描述: 货架确认调整完成接口<br>
        *
        * @param principal
        * @param adjustId
        * @param shelfNo
        * @return
        */
        @RequestMapping("/shelf/processShelfAdjust.do")
        public MyGsonView processShelfAdjust(Principal principal, String adjustId, String shelfNo) {
            LOGGER.info("货架确认调整完成接口, staffId: {}, adjustId: {}, shelfNo: {}", principal.getName(), adjustId, shelfNo);
            ReturnMsg<String> result = new ReturnMsg<String>();
            //工号
            String staffId = principal.getName();
            //查询店员信息
            StoreManDto storeMan = storeManService.queryStoreManAttachInfo(staffId);
            //门店编号
            String storeCode = storeMan.getStoreCode();
            try {
                intellegentShelfService.processShelfAdjust(storeCode, shelfNo, adjustId);
            } catch (Exception e) {
                result.setRetFlag(ReturnMsg.FAIL);
                result.setErrorCode(ErrorCodeConstants.ERR_0002);
                result.setErrorMessage(e.getMessage());
                LOGGER.error("货架确认调整完成接口异常, adjustId: {}, shelfNo: {}", principal.getName(), adjustId, shelfNo, e);
            }
            return setGsonView(result);
        }
        
        /**
         * 
         * 功能描述: 查询货架列表<br>
         *
         * @param principal
         * @param limit
         * @param startIndex
         * @return
         */
         @RequestMapping("/shelf/queryShelfList.do")
         public MyGsonView queryShelfList(Principal principal, Integer limit, Integer startIndex) {
             LOGGER.info("查询货架列表, staffId: {}, limit: {}, startIndex: {}", principal.getName(), limit, startIndex);
             ReturnMsg<StoreShelfDto> result = new ReturnMsg<StoreShelfDto>();
             //工号
             String staffId = principal.getName();
             //查询店员信息
             StoreManDto storeMan = storeManService.queryStoreManAttachInfo(staffId);
             //门店编号
             String storeCode = storeMan.getStoreCode();
             staffId = getStaffId(staffId, storeMan.getPositionId());
             try {
                 result.setData(intellegentShelfService.queryShelfList(storeCode, staffId, startIndex, getEnd(startIndex, limit)));
             } catch (Exception e) {
                 result.setRetFlag(ReturnMsg.FAIL);
                 result.setErrorCode(ErrorCodeConstants.ERR_0002);
                 result.setErrorMessage(e.getMessage());
                 LOGGER.error("查询货架列表异常, limit: {}, startIndex: {}", principal.getName(), limit, startIndex, e);
             }
             return setGsonView(result);
         }
      
         /**
          * 
          * 功能描述: 店员确认补货接口<br>
          *
          * @param principal
          * @param cmmdtyCode
          * @param shelfNo
          * @return
          */
          @RequestMapping("/shelf/replenishShelfCmmdty.do")
          public MyGsonView replenishShelfCmmdty(Principal principal, String cmmdtyCode, String shelfNo) {
              LOGGER.info("店员确认补货接口, staffId: {}, cmmdtyCode: {}, shelfNo: {}", principal.getName(), cmmdtyCode, shelfNo);
              ReturnMsg<String> result = new ReturnMsg<String>();
              //工号
              String staffId = principal.getName();
              //查询店员信息
              StoreManDto storeMan = storeManService.queryStoreManAttachInfo(staffId);
              //门店编号
              String storeCode = storeMan.getStoreCode();
              try {
                  intellegentShelfService.replenishShelfCmmdty(storeCode, shelfNo, cmmdtyCode);
              } catch (Exception e) {
                  result.setRetFlag(ReturnMsg.FAIL);
                  result.setErrorCode(ErrorCodeConstants.ERR_0002);
                  result.setErrorMessage(e.getMessage());
                  LOGGER.error("店员确认补货接口异常, staffId: {}, cmmdtyCode: {}, shelfNo: {}", principal.getName(), cmmdtyCode, shelfNo, e);
              }
              return setGsonView(result);
          }
          
    
    /**
     * 
     * 功能描述: 查询卡单信息<br>
     *
     * @param storeCode
     * @return
     */
    private ExpOrderDetail queryExpOrderSummaryDetail(String storeCode){
        //只有店长或者督导角色才能查询
        ExpOrderQueryDetailDto expOrderQueryDetailDto = new ExpOrderQueryDetailDto();
        expOrderQueryDetailDto.setStoreCode(storeCode);
        expOrderQueryDetailDto.setPage(MemberConstants.ONE_PAGE);
        expOrderQueryDetailDto.setPageSize(MemberConstants.PAGE_SIZE);
        return exceptionOrderService.queryExpOrderSummaryDetail(expOrderQueryDetailDto);
    }
    
    /**
     * 
     * 功能描述: 查询本月销售<br>
     *
     * @param storeCode
     * @return
     */
    private BigDecimal querySaleAmount4thisMonth(String storeCode){
        BigDecimal saleAmount = BigDecimal.ZERO;
        String month = DateUtils.getThisMonth();
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("month", month);
        params.put("storeCode", storeCode);
        BiStoreSaleMonthDto monthSale = dalClient.queryForObject("BI_STORE_DATA_WAP.QUERY_STORE_SALE_MONTH", params, BiStoreSaleMonthDto.class);
        // 当月销售额
        if (null != monthSale && StringUtils.isNotBlank(monthSale.getSaleAmount())) {
            saleAmount = DJStringUtils.bigDecimal(monthSale.getSaleAmount());
        }
        return BigDecimalUtils.halfUpTwoDecimal(saleAmount);
    }
    
    /**
     * 
     * 功能描述: 按单位处理金额<br>
     *
     * @param value
     * @return
     */
    private Map<String, String> handleAmount(BigDecimal value){
        Map<String, String> amountMap = new HashMap<String, String>();
        String unit = BiSaleAmountDto.UNIT_NORMAL;
        if(null == value){
            value = BigDecimal.ZERO;
        }else if(value.compareTo(DJStringUtils.bigDecimal("9999")) > 0){
            value = value.divide(BigDecimal.valueOf(BiSaleAmountDto.WAN), BiSaleAmountDto.SCALE_TWO, 
                    BigDecimal.ROUND_HALF_EVEN);
            unit = BiSaleAmountDto.UNIT_WAN;
        }
        amountMap.put("amount", String.valueOf(BigDecimalUtils.halfUpTwoDecimal(value)));
        amountMap.put("unit", unit);
        return amountMap;
    }
    
    private Integer getEnd(Integer startIndex, Integer limit){
        return startIndex + limit - 1;
    }
    
    private String getStaffId(String staffId, String positionId){
        //督导店长品类经理不需要传工号
        if(ClerkConstants.STORE_KEEPER.equals(positionId) || ClerkConstants.SALE_GUIDE.equals(positionId) 
                || ClerkConstants.CATE_MANAGER.equals(positionId)){
            staffId =  null;
        }
        return staffId;
    }
    
}
